<!DOCTYPE html>
<html>
<head>
<head/>
<div th:include="base-libs :: base-libs" />
<div th:include="common/yljg-modal :: yljg-modal" />
<div th:include="common/common-export :: common-export" />
<title>签约列表</title>
<style type="text/css">
.tabs-wrap>.tabs>li>a{
	border-left:1px solid #438EB9!important;
	border-right:1px solid #438EB9!important;
	border-top:1px solid #438EB9!important;
}
.laydate-icon{
	border:1px solid #B6B6B6
}
</style>
</head>
<script th:inline="javascript">
	/**用户信息*/
	var userInfo = [[${userInfo}]];
</script>
<script type="text/javascript">
$(function() {
    $(this).registerManagerPage();
    enterToQuery(queryQylbForm);
 	initView();
});

function queryQylbForm(){
	$("#qylb").datagrid("reload");
}

function queryQyjsForm(){
	$("#qyjs").datagrid("reload");
}

function queryJyshForm(){
	$("#jysh").datagrid("reload");
}


function initView()
{
	var select = StoreCache.removeCache("QYLB_SELECT");
	if(select){
		$("#tabbleQylb").tabs("select",parseInt(select));
	}
	/**加载签约列表*/
	initQylb();
	/**加载签约待接收列表*/
	initQyjs();
	/**加载签约待解约列表*/
	initJysh();
	/**加载tabs*/
	$("#tabbleQylb").tabs({    
	    border:false,
	    fit: true,
	    tabWidth: "200",
	    onSelect:function(title, index){  
			    	if(index == 0){
			    		 enterToQuery(queryQylbForm);
			    	}
			    	else if(index == 1){
			    		 enterToQuery(queryQyjsForm);
			    	}
					else if(index == 2){
						 enterToQuery(queryJyshForm);
			    	}
			}
	    });
	/**平台管理员只显示签约列表，需确定平台管理员*/
	if((userInfo["WSJGLBDM"]).substr(0,1) == "R"){
		$("#tabbleQylb").tabs("close","签约接收");
		$("#tabbleQylb").tabs("close","解约审核");
	}
	/**各个查询按钮*/
	$("#btnQuery").on("click", function(){
		queryQylbForm();//$("#qylb").datagrid("reload");
	});
	$("#btnQuery1").on("click", function(){
		queryQyjsForm();//$("#qyjs").datagrid("reload");	
	});
	$("#btnQuery2").on("click", function(){
		queryJyshForm();//$("#jysh").datagrid("reload");
	});
	
	
	$("#btnExport").on("click", function(){
		exportForm('exportForm');
	});
	$("#btnExport1").on("click", function(){
		exportForm('exportForm1');
	});
	$("#btnExport2").on("click", function(){
		exportForm('exportForm2');
	});
}

/**导出*/
function exportForm(formName){
	$(".PTJGID").val(userInfo.PTJGID);
	$("#" + formName).submit();
}

/**加载签约列表table信息*/
function initQylb(){
	$("#qylb").datagrid(getOption("qylb"));
}

/**加载签约接收table信息*/
function initQyjs(){
	$("#qyjs").datagrid(getOption("qyjs"));
}

/**加载解约审核table信息*/
function initJysh(){
	$("#jysh").datagrid(getOption("jysh"));
}

function getOption(lx){
	var tool = "#dgFormToolbar";
	if(lx == "qyjs"){
		tool = "#dgFormToolbar1";
	}else if(lx == "jysh"){
		tool = "#dgFormToolbar2";
	}
	var opt = {
			idField : "YLJGID",
			uniqueId: "YLTID",
			striped : true,
			border:false,
			toolbar : tool,
			columns : [[
				//{field: "checkStatus",checkbox: true},
				{field : "YLTMC",width: 150,align: "center",title : "医联体名称",
					formatter : function(value, row, index){
						return $("<a class='tableToolBarBtn' title='"+value+"' >"+value+"</a>").attr("href","javascript:detail('"+row["YLTID"]+"','"+lx+"')").prop("outerHTML");
					}
				},
				{field : "ZDYLJGMC",width: 200,align: "center",title : "主导机构"},
				{field : "YLJGMC",width: 200,align: "center",title : "签约机构"},
				{field : "YLTLXMC",width: 100,align: "center",title : "医联体类型"},
				{field : "CJSJ",width: 100,align: "center",title : "申请时间",
					formatter : function(value, row, index){
						if(!StringUtils.isEmpty(value)){
							value = value.substr(0, 10);
						}
						return value;
					}
				},
				{field : "QYYXQMC",width: 100,align: "center",title : "签约有效期"},
				{field : "QYZTMC",width: 100,align: "center",title : "状态"},
				{field : "cz",width: 100,align: "center",title : "操作",formatter : function(value, row, index){
					var cz;
					if(lx=="qylb"){
						if(row["QYZT"]=="03"){
							if(row["YLJGID"] == userInfo["PTJGID"] || row["SFXY"] == "1"){
								cz = $("#tableToolBarJy").html();
							}else{
								cz = $("#tableToolBarLb").html();
							}
						}
						else{
							cz = $("#tableToolBarXq").html();
							return cz.replace(/#yltid#/g, row["YLTID"]).replace(/#lx#/g,lx);
						}
					}
					else if(lx=="qyjs"){
						cz = $("#tableToolBarJs").html();
					}
					else if(lx=="jysh"){
						cz = $("#tableToolBarSh").html();
					}
					
					return cz.replace(/#index#/g,index).replace(/#lx#/g,lx);
				}}
			]]
			,pagination : true
			,pageNumber: 1
			,pageSize: 10
			,fit: true
			,fitColumns: true
			,singleSelect: true
			,rownumbers: true
			,method : "post"
			,url: contextRoot+"qylb/queryPage.service"
			,onBeforeLoad:function(params){
				params["LX"] = lx;
				if(lx == "qylb"){
					params["ZDYLJGID"] = userInfo["PTJGID"];
					params["ZDYLJGMC"] = $("#YLJGMC").val();
					params["YLTLX"] = $("#YLTLX").val();
					params["CJSJ"] = $("#CJSJ").val();
					params["QYZT"] = $("#QYZT").val();
					
				}
				else if(lx == "qyjs"){
					params["YLJGID"] = userInfo["PTJGID"];
					params["ZDYLJGMC"] = $("#YLJGMC1").val();
					params["YLTLX"] = $("#YLTLX1").val();
					params["CJSJ"] = $("#CJSJ1").val();
					params["QYZT"] = "02";
				}
				else if(lx == "jysh"){
					params["ZDYLJGID"] = userInfo["PTJGID"];
					params["JYFQJGID"] = userInfo["PTJGID"];
					params["ZDYLJGMC"] = $("#YLJGMC2").val();
					params["YLTLX"] = $("#YLTLX2").val();
					params["CJSJ"] = $("#CJSJ2").val();
					params["QYZT"] = "07";
				}
				return params;
			}
		};
	return opt;
}

/**校验是否选中签约申请*/
function validate(info){
	if(StringUtils.isEmpty(info)){
		return false;
	}else{
		return true;
	}
}

/* var start = {
	    elem: '#KSSJ',
	    choose: function(datas){
	    	end.min = datas; //开始日选好后，重置结束日的最小日期
	    	end.start = datas; //将结束日的初始值设定为开始日
	    }
	};
var end = {
	    elem: '#JSSJ',
	    choose: function(datas){
	    	start.max = datas; //结束日选好后，重置开始日的最大日期
	    }
	};
var start1 = {
	    elem: '#KSSJ1',
	    choose: function(datas){
	    	end.min = datas; //开始日选好后，重置结束日的最小日期
	    	end.start = datas; //将结束日的初始值设定为开始日
	    }
	};
var end1 = {
	    elem: '#JSSJ1',
	    choose: function(datas){
	    	start.max = datas; //结束日选好后，重置开始日的最大日期
	    }
	};	
var start2 = {
	    elem: '#KSSJ2',
	    choose: function(datas){
	    	end.min = datas; //开始日选好后，重置结束日的最小日期
	    	end.start = datas; //将结束日的初始值设定为开始日
	    }
	};
var end2 = {
	    elem: '#JSSJ2',
	    choose: function(datas){
	    	start.max = datas; //结束日选好后，重置开始日的最大日期
	    }
	};	 */
	
	/**解约*/
	function jyFunc(index, lx){
		/**清除所有选择*/
		$("#qyjs").datagrid("clearSelections");
		/**选中当前行*/
		$("#qyjs").datagrid("selectRow", index);
		/**获取选中行数据*/
		var row = $("#qylb").datagrid("getSelected", index);
		var url = "jy.html?YLTID="+row["YLTID"]+"&GLID="+row["GLID"]+"&YLJGID="+userInfo["PTJGID"];
		StoreCache.setCache("QYLB_SELECT", 0);
		$.QuickUrlUtils.redirectUrl(url);
	}
	
	/**续约*/
	function xyFunc(index, lx){
		/**清除所有选择*/
		$("#qysqForm").datagrid("clearSelections");
		/**选中当前行*/
		$("#qysqForm").datagrid("selectRow", index);
		/**获取选中行数据*/
		var row = $("#qylb").datagrid("getSelected", index);
		StoreCache.setCache("QYLB_SELECT", 0);
		$.QuickUrlUtils.redirectUrl("xy.html?YLTID="+row["YLTID"]);
	}
	
	/**接收*/
	function jsFunc(index){
		/**清除所有选择*/
		$("#qyjs").datagrid("clearSelections");
		/**选中当前行*/
		$("#qyjs").datagrid("selectRow", index);
		/**获取选中行数据*/
		var row = $("#qyjs").datagrid("getSelected", index);
		var url = "jieshou.html?YLTID="+row["YLTID"]+"&GLID="+row["GLID"];
		if(row["JGLX"] == "2"){
			url += "&YLJGID="+row["YLJGID"];
		}
		StoreCache.setCache("QYLB_SELECT", 1);
		$.QuickUrlUtils.redirectUrl(url);
	}
	
	/**解约审核*/
	function jyshFunc(index, lx){
		/**清除所有选择*/
		$("#jysh").datagrid("clearSelections");
		/**选中当前行*/
		$("#jysh").datagrid("selectRow", index);
		/**获取选中行数据*/
		var row = $("#jysh").datagrid("getSelected", index);
		StoreCache.setCache("QYLB_SELECT", 2);
		var url = "jysh.html?YLTID="+row["YLTID"]+"&GLID="+row["GLID"]+"&YLJGID="+row["JYFQJGID"]
					+"&JYYY="+row["JYYYMC"];
		$.QuickUrlUtils.redirectUrl(url);
	}
	
	/**详情*/
	function detail(yltid,lx){
		var url = "detail.html?YLTID="+yltid;
		window.open(url);
		/* if("qylb"==lx){
			StoreCache.setCache("QYLB_SELECT", 0);
		}
		else if("qyjs"==lx){
			StoreCache.setCache("QYLB_SELECT", 1);
		}
		else if("jysh"==lx){
			StoreCache.setCache("QYLB_SELECT", 2);
		} 
		$.QuickUrlUtils.redirectUrl(url);*/
	}
</script>

<body>
	<div id="tabbleQylb" class="easyui-tabs" data-options="fit:true">   
	    <div title="签约列表" style="display:none;">   
	        <div class="easyui-layout" style="border: none;" data-options="fit:true">
				<div region="center" style="border: none;">
					<div id="dgFormToolbar" style="background: white;">
						<form id="exportForm" action="export.service" enctype="multipart/form-data">
							<table class="form-table" style="margin:0;padding:0;width:100%">
								<tr>
									<td class="td-text">主导机构名称：</td>
									<td class="td-content">
										<input type="hidden" name="LX" value="qylb"/>
										<input type="hidden" class="PTJGID" name="ZDYLJGID" />
									
										<input id="YLJGMC" name="ZDYLJGMC" type="text"/>
									</td>
									<td class="td-text">医联体类型：</td>
									<td class="td-content">
										<select id="YLTLX" name="YLTLX" class="form-control" cacheTable="TB_ZY_YLTLX">
										</select>
									</td>
									</td>
									
									<td class="td-text">申请时间：</td>
									<td class="td-content">
										 <input id="CJSJ" name="CJSJ" style="width:85%;height:30px;"
											class="input-text laydate-icon dataField" onclick="laydate()" />
										<!-- - <input id="JSSJ" name="JSSJ" style="width:35%;height:30px;"
											class="input-text laydate-icon dataField" onclick="laydate(end)" /> -->
									</td>
									<td class="td-text" style="text-align:center;width:160px;">
										<button class="btn btn-info" type="button" id="btnQuery">查询</button>
										<button id="btnExport" class="btn btn-info" type="button">导出</button>
									</td>
								</tr>
								<tr>
									<td class="td-text">状态：</td>
									<td cla.ss="td-content">
										<select id="QYZT" name="QYZT"  style="width:91%">
											<option value="">请选择</option>
											<option value="03">已签约</option>
											<option value="05">已解约</option>
											<option value="06">已到期</option>
										</select>
									</td>
								</tr>
							</table>
						</form>
					</div>
					<table id="qylb">
					</table>
				</div>
			</div>  
	    </div>   
	    <div title="签约接收" style="overflow:hidden;display:none;">   
	         <div class="easyui-layout" style="border: none;" data-options="fit:true">
				<div region="center" style="border: none;">
					<div id="dgFormToolbar1" style="background: white;">
						<form id="exportForm1" action="export.service" enctype="multipart/form-data">
							<table class="form-table" style="margin:0;padding:0;width:100%">
								<tr>
									<td class="td-text">主导机构名称：</td>
									<td class="td-content">
										<input type="hidden" name="LX" value="qyjs"/>
										<input type="hidden" name="YLJGID" class="PTJGID" />
										<input type="hidden" name="QYZT" value="02" />
									
										<input id="YLJGMC1" type="text" name="ZDYLJGMC" />
									</td>
									<td class="td-text">医联体类型：</td>
									<td class="td-content">
										<select id="YLTLX1" name="YLTLX" class="form-control" cacheTable="TB_ZY_YLTLX">
										</select>
									</td>
									</td>
									
									<td class="td-text">申请时间：</td>
									<td class="td-content">
										 <input id="CJSJ1" name="CJSJ" style="width:85%;height:30px;"
											class="input-text laydate-icon dataField" onclick="laydate()" />
										<!-- - <input id="JSSJ1" name="JSSJ" style="width:35%;height:30px;"
											class="input-text laydate-icon dataField" onclick="laydate(end1)" /> -->
									</td>
									<td class="td-text" style="text-align:center;width:160px;">
										<button id="btnQuery1" class="btn btn-info" type="button">查询</button>
										<button id="btnExport1" class="btn btn-info" type="button">导出</button>
									</td>
								</tr>
							</table>
						</form>
					</div>
					<table id="qyjs">
					</table>
				</div>
			</div>     
	    </div>   
	    <div title="解约审核"  style="display:none;overflow:hidden">   
	         <div class="easyui-layout" style="border: none;" data-options="fit:true">
				<div region="center" style="border: none;">
					<div id="dgFormToolbar2" style="background: white;">
						<form id="exportForm2" action="export.service" enctype="multipart/form-data">
							<table class="form-table" style="margin:0;padding:0;width:100%">
								<tr>
									<td class="td-text">主导机构名称：</td>
									<td class="td-content">
										<input type="hidden" name="LX" value="jysh"/>
										<input type="hidden" name="ZDYLJGID" class="PTJGID" />
										<input type="hidden" name="JYFQJGID" class="PTJGID" />
										<input type="hidden" name="QYZT" value="07" />
									
										<input id="YLJGMC2" name="ZDYLJGMC" type="text"/>
									</td>
									<td class="td-text">医联体类型：</td>
									<td class="td-content">
										<select id="YLTLX2" name="YLTLX" class="form-control" cacheTable="TB_ZY_YLTLX">
										</select>
									</td>
									</td>
									
									<td class="td-text">申请时间：</td>
									<td class="td-content">
										 <input id="CJSJ2" name="CJSJ" style="width:85%;height:30px;"
											class="input-text laydate-icon dataField" onclick="laydate()" />
										<!-- - <input id="JSSJ2" name="JSSJ" style="width:35%;height:30px;"
											class="input-text laydate-icon dataField" onclick="laydate(end2)" /> -->
									</td>
									<td class="td-text" style="text-align:center;width:160px;">
										<button id="btnQuery2" class="btn btn-info" type="button" >查询</button>
										<button id="btnExport2" class="btn btn-info" type="button">导出</button>
									</td>
								</tr>
							</table>
						</form>
						<!-- <div style="margin:10px 10px auto 0px;">
							<button id="btnExport2" class="btn btn-info" type="button">导出</button>
						</div> -->
					</div>
					<table id="jysh">
					</table>
				</div>
			</div>     
	    </div>   
	</div>  
</body>
<script type="text/html" id="tableToolBarLb">
<a class="tableToolBarBtn" href="javascript:jyFunc(#index#,'#lx#')" title="解约" >解约</a>
<a class="tableToolBarBtn" href="javascript:xyFunc(#index#,'#lx#')" title="续约" >续约</a>
</script>
<script type="text/html" id="tableToolBarJy">
<a class="tableToolBarBtn" href="javascript:jyFunc(#index#,'#lx#')" title="解约" >解约</a>
</script>
<script type="text/html" id="tableToolBarSh">
<a class="tableToolBarBtn" href="javascript:jyshFunc(#index#,'#lx#')" title="审核" >审核</a>
</script>
<script type="text/html" id="tableToolBarJs">
<a class="tableToolBarBtn" href="javascript:jsFunc(#index#)" title="接收" >接收</a>
</script>
<script type="text/html" id="tableToolBarXq">
<a class="tableToolBarBtn" href="javascript:detail('#yltid#','#lx#')" title="详情" >详情</a>
</script>
</html>



